// ValidationAspects
// Written by Mike Saunders
// Released under Microsoft Public License (Ms-PL)
using NUnit.Framework;
using ValidationAspects.Exceptions;
using ValidationAspects.Factories;
using ValidationAspects.Sdk;

namespace TestValidationAspects.Factories
{
	[TestFixture]
	public class TestNotNullOrEmpty
	{
		[Test]
		[ExpectedException(typeof(UnsupportedValidationException))]
		public void Test_CreateValidator_throws_for_unsupported_type()
		{
			new NotNullOrEmpty().Create<object>();
		}

		[Test]
		public void Test_NotNullOrEqual()
		{
			IValidator<string> validator = new NotNullOrEmpty().Create<string>();

			Test.Throws<ValidateNotNullOrEmptyException>(() => validator.Invoke(null, new MockValidationContext()), new ValidateNotNullOrEmptyException().Message);
			Test.Throws<ValidateNotNullOrEmptyException>(() => validator.Invoke(string.Empty, new MockValidationContext()), new ValidateNotNullOrEmptyException().Message);
			validator.Invoke("text", new MockValidationContext());
		}
	}
}